package com.wpw.dream.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;

public class FutureTaskDemo {

	public static void main(String[] args) {
		ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
		newCachedThreadPool.submit(new ResultTask(new ThreadTask()));
	}
}

class ThreadTask implements Callable<String> {

	@Override
	public String call() throws Exception {
		Thread.sleep(3000);
		System.out.println("这是线程！");
		return null;
	}
	
}

class ResultTask extends FutureTask<String> {

	public ResultTask(Callable<String> callable) {
		super(callable);
	}

	@Override
	protected void done() {
		System.out.println("完成了");
	}
	
}